import {handleLogin} from "./api/api"

// app.js
App({
    onLaunch() {
        // 登录
        wx.login({
            success: res => {
                // 发送 res.code 到后台换取 openId, sessionKey, unionId
                handleLogin({
                    code: res.code
                })
                    .then(res => {
                        getApp().globalData.token = res.data.token
                        getApp().globalData.phone = res.data.phone
                        getApp().globalData.cup = res.data['7cup']
                    })
            }
        })
    }, globalData: {
        cup: 0,
        total: 0,
        count: 0,
        token: '',
        phone: '',
        selectedProduct: [],
        couponList: [],
        selectedCoupon: '',
        userInfo:{}
    }
})
